Skip to content

Feat: cache discovery results and extract shared get_model_info#62

Closed
cosminacho wants to merge 2 commits into
mainfrom
feat/cache-discovery-results
Closed

Feat: cache discovery results and extract shared get_model_info#62
cosminacho wants to merge 2 commits into
mainfrom
feat/cache-discovery-results

Conversation

@cosminacho

Copy link
Copy Markdown
Collaborator

Summary

  • Cache get_available_models() with @lru_cache on both PlatformSettings and LLMGatewaySettings, avoiding redundant discovery endpoint calls when creating multiple models in a session
  • Extract shared get_model_info() utility to uipath.llm_client.utils.discovery — the model lookup logic (filter by name, vendor, BYOM connection ID, prefer UiPath-owned) was duplicated between the langchain factory and litellm client
  • Add __hash__ = object.__hash__ to UiPathBaseSettings so @lru_cache works on instance methods (pydantic models aren't hashable by default)

Packages affected: core + langchain

Test plan

  • Cache tests: second call returns cached result without hitting endpoint (LLMGateway + Platform)
  • Cache is per-instance (different settings instances get separate cache entries)
  • get_model_info tests: name matching, case-insensitive, vendor filter, BYOM connection ID filter, UiPathOwned preference, error cases
  • All existing tests pass (ruff check && ruff format --check && pyright && pytest tests — 1519 passed)

🤖 Generated with Claude Code

cosminacho and others added 2 commits April 16, 2026 23:37
…nfo (#62)

Add TTL-based caching (5 min) for get_available_models() to avoid
redundant discovery calls when creating multiple models in a session.
Extract shared model lookup logic into get_model_info() utility in the
core package, reused by both the langchain factory and litellm client.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cosminacho cosminacho closed this Apr 17, 2026
@cosminacho cosminacho deleted the feat/cache-discovery-results branch April 17, 2026 05:45
cosminacho added a commit that referenced this pull request Apr 17, 2026
Add caching for model discovery and centralize model lookup logic in
UiPathBaseSettings so all consumers (LangChain factory, LiteLLM client)
share the same cached discovery and filtering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant